package com.mrxy.mouse.controller;

import com.mrxy.mouse.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/11/7 20:33
 */
@Controller
public class PageController
{
    @Autowired
    private UserService userService;

    @RequestMapping("index")
    public String index()
    {
        return "index.html";
    }

    @PostMapping("/mr/register")
    @ResponseBody
    public String register(String username, String password)
    {
        if (username != null && password != null)
        {
            boolean flag = userService.register(username, password);
            if (flag)
            {
                return "注册成功！";
            }
        }
        return "注册失败！";
    }
}
